package com.pet.dao.imp;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.pet.dao.OperateDb;
import com.pet.inter.bean.TopicBackBean;
import com.pet.inter.bean.TopicBean;
import com.pet.inter.bean.UserInfoBean;

public class OperateDbImp extends SqlMapClientDaoSupport implements OperateDb{
	private static final Log log = LogFactory.getLog(OperateDbImp.class);
	public Map queryUserInfo(Map<String, String> paramMap) {
		Map d = (Map)getSqlMapClientTemplate().queryForMap("UserInfo.queryUserInfo", paramMap, "userid");
		log.info("result = " + d);
		return d;
	}
	public int insertUserInfo(Map<String, String> paramMap){
		int rs = 0;
		try{
			rs = getSqlMapClientTemplate().update("UserInfo.insertUserInfo", paramMap);
		}catch(Exception e){
			log.info("result = " + e.getMessage());
		}
		log.info("rs = " + rs);
		return rs;
	}
	
	public UserInfoBean queryUserInfos(Map<String, String> paramMap) {
		log.info("paramMap = " + paramMap);
		UserInfoBean d = (UserInfoBean)getSqlMapClientTemplate().queryForObject("UserInfo.queryUserInfos", paramMap);
		log.info("result = " + d);
		return d;
	}
	public int updatetUserInfo(Map<String, String> paramMap) {
		int rs = 0;
		try{
			rs = getSqlMapClientTemplate().update("UserInfo.updateUserInfo", paramMap);
		}catch(Exception e){
			log.info("result = " + e.getMessage());
		}
		log.info("rs = " + rs);
		return rs;
	}
	public int insertTopicInfo(Map<String, String> paramMap) {
		int rs = 0;
		try{
			rs = getSqlMapClientTemplate().update("TopicInfo.insertTopicInfo", paramMap);
		}catch(Exception e){
			log.info("result = " + e.getMessage());
		}
		log.info("rs = " + rs);
		return rs;
	}
	public List<TopicBean> queryTopicsInfos(Map<String, String> paramMap) {
		List<TopicBean> returnRs = getSqlMapClientTemplate().queryForList("TopicInfo.queryTopicsInfo", paramMap);
		return returnRs;
	}
	public int insertTopicBackInfo(Map<String, String> paramMap) {
		int rs = 0;
		try{
			rs = getSqlMapClientTemplate().update("TopicInfo.insertTopicBackInfo", paramMap);
		}catch(Exception e){
			log.info("result = " + e.getMessage());
		}
		log.info("rs = " + rs);
		return rs;
	}
	public List<TopicBackBean> queryTopicBacksInfos(Map<String, String> paramMap) {
		List<TopicBackBean> returnRs = getSqlMapClientTemplate().queryForList("TopicInfo.queryTopicBacksInfo", paramMap);
		return returnRs;
	}
}
